<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    

    <title>Flex学习 | yale前端技术博客</title>
    <meta name="author" content="Yale">
    
    <meta name="description" content="Flexbox是弹性盒子的引文缩写flexible-box,弹性盒子布局是新的CSS3布局模型，它主要用于…">
    
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <meta property="og:title" content="Flex学习"/>
    <meta property="og:site_name" content="Yale"/>

    
    <meta property="og:image" content="undefined"/>
    

    <link rel="icon" type="image/png" href="/favicon.png">
    <link rel="alternate" href="/atom.xml" title="Yale" type="application/atom+xml">
    <link rel="stylesheet" href="/css/lib/materialize.min.css">
    <link rel="stylesheet" href="/css/lib/font-awesome.min.css">
    <link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">

    
        <link rel="stylesheet" href="/css/lib/prettify-tomorrow-night-eighties.css" type="text/css">
    
    <!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>


<body>
    <nav class="orange">
    <div class="nav-wrapper">
        <a href="#" data-activates="main-menu" class="button-collapse">
            <i class="fa fa-navicon"></i>
        </a>
        <div class="">
            <a href="/" class="brand-logo hide-on-med-and-down">Yale</a>
            <ul class="right hide-on-med-and-down">
                
                    <li>
                        <a class="menu-home " href="/" >
                            <i class="fa fa-home "></i>
                            
                            首页
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-archive " href="/archives" >
                            <i class="fa fa-archive "></i>
                            
                            归档
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-category category-menu" href="javascript:;" data-activates="category-menu" >
                            <i class="fa fa-bookmark "></i>
                            
                            分类
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-reading " href="/reading" >
                            <i class="fa fa-book "></i>
                            
                            读书
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-about " href="/about" >
                            <i class="fa fa-user "></i>
                            
                            关于
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-search modal-trigger " href="#search" >
                            <i class="fa fa-search "></i>
                            
                            搜索
                        </a>
                    </li>
                
            </ul>
            <div>
    <ul class="side-nav indigo darken-1" id="main-menu">
        
        <li class="side-user">
            <div class="row">
                <div class="col s4 no-padding">
                    <img class="avatar-image circle responsive-img" src="http://ww2.sinaimg.cn/small/74990035jw1f1rjkd681bj20rs0rsdhg.jpg" alt="User Avatar">
                </div>
                <div class="info col s8 valign-wrapper no-padding">
                    <div class="valign">
                        <p class="name">Yale</p>
                        <p class="desc">Web前端/Nodejs/技术宅</p>
                    </div>
                </div>
            </div>
        </li>
        

        
            <li class="no-padding">
                <a class="waves-effect menu-home " href="/" >
                    <i class="fa fa-home "></i>
                    
                    首页
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-archive " href="/archives" >
                    <i class="fa fa-archive "></i>
                    
                    归档
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-category category-menu" href="javascript:;" data-activates="category-menu" >
                    <i class="fa fa-bookmark "></i>
                    
                    分类
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-reading " href="/reading" >
                    <i class="fa fa-book "></i>
                    
                    读书
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-about " href="/about" >
                    <i class="fa fa-user "></i>
                    
                    关于
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-search modal-trigger " href="#search" >
                    <i class="fa fa-search "></i>
                    
                    搜索
                </a>
            </li>
        
    </ul>

    <ul class="side-nav indigo darken-1" id="category-menu">
    

            

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/CSS3/">
                    CSS3 <span class="right">3 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/CSS3/CSS3笔记/">
                    CSS3笔记 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/CSS3/Flex学习笔记/">
                    Flex学习笔记 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/CSS3/SVG/">
                    SVG <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/HTML5/">
                    HTML5 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/HTML5/HTML5笔记/">
                    HTML5笔记 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/Javascript/">
                    Javascript <span class="right">2 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/Javascript/JavaScript基础知识总结1/">
                    JavaScript基础知识总结1 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/Javascript/JavaScript基础知识总结2/">
                    JavaScript基础知识总结2 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/WebSocket/">
                    WebSocket <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/WebSocket/WebSocket实例运用/">
                    WebSocket实例运用 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/学习随想/">
                    学习随想 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/学习随想/学习随想1/">
                    学习随想1 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/ES6/">
                    ES6 <span class="right">3 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/ES6/ES6中数组和函数的扩展/">
                    ES6中数组和函数的扩展 <span class="right">2 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/ES6/ES6中变量声明、解构赋值、模版字符串/">
                    ES6中变量声明、解构赋值、模版字符串 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/微信小程序/">
                    微信小程序 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/微信小程序/微信小程序笔记/">
                    微信小程序笔记 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/nodejs/">
                    nodejs <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/nodejs/nodejs笔记1/">
                    nodejs笔记1 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/常用软件下载地址/">
                    常用软件下载地址 <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/常用软件下载地址/软件下载地址/">
                    软件下载地址 <span class="right">1 篇</span></a>
                </a>
            </li>

        

    </ul>
</div>

        </div>
    </div>
</nav>

<div id="search" class="modal search-modal">
    <div class="row">
        <div class="input-field col s12">
              <input id="search-input" type="text">
              <label for="search-input">搜索</label>
        </div>

    </div>
    <div id="search-result" class="search-result col s12">

    </div>
</div>


    <main>
        <div class="container main-container">
    <nav class="page-nav hide-on-small-only">
    <div class="nav-wrapper indigo">
        <span class="breadcrumb">当前位置（分类目录）</span>
        
            
    
    
    <a class="breadcrumb" href="/categories/CSS3/">CSS3</a><a class="breadcrumb" href="/categories/CSS3/Flex学习笔记/">Flex学习笔记</a>


        

        
    </div>
</nav>

<article>
    <div class="card">
        <div class="card-content">
            

            <div class="article-title">
                
    
        <h1>Flex学习</h1>
    


            </div>
            <time class="pink-link-context" datetime="2016-01-14T16:00:00.000Z"><a href="/2016/01/15/Flex学习/">2016-01-15</a></time>

            <span id="busuanzi_container_page_pv" class="read-times-container">
    <i class="fa fa-eye"></i>
    <span id="busuanzi_value_page_pv"></span>
</span>

            
    <div class="tags-row">
        
            <a href="/tags/CSS3知识总结/" class="chip pink lighten-1">CSS3知识总结</a>
        
    </div>


            <div class="toc pink-link-context hide-on-med-and-down">
    <ol class="section table-of-contents"><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#flex是什么？"><span class="section table-of-contents-text">flex是什么？</span></a></li><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#flex容器的主要特点"><span class="section table-of-contents-text">flex容器的主要特点</span></a></li><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#Flex的使用范围及注意"><span class="section table-of-contents-text">Flex的使用范围及注意</span></a></li><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#flex容器及flex容器子元素示意图"><span class="section table-of-contents-text">flex容器及flex容器子元素示意图</span></a></li><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#flexbox的属性"><span class="section table-of-contents-text">flexbox的属性</span></a></li><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#flex容器属性"><span class="section table-of-contents-text">flex容器属性</span></a><ol class="section table-of-contents-child"><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#flex-direction"><span class="section table-of-contents-text">flex-direction</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#flex-wrap"><span class="section table-of-contents-text">flex-wrap</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#flex-flow"><span class="section table-of-contents-text">flex-flow</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#justify-content"><span class="section table-of-contents-text">justify-content</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#align-items"><span class="section table-of-contents-text">align-items</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#align-content"><span class="section table-of-contents-text">align-content</span></a></li></ol></li><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#flex容器子元素属性"><span class="section table-of-contents-text">flex容器子元素属性</span></a><ol class="section table-of-contents-child"><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#order"><span class="section table-of-contents-text">order</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#flex-grow"><span class="section table-of-contents-text">flex-grow</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#flex-shrink"><span class="section table-of-contents-text">flex-shrink</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#flex-basis"><span class="section table-of-contents-text">flex-basis</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#flex"><span class="section table-of-contents-text">flex</span></a></li><li class="section table-of-contents-item section table-of-contents-level-3"><a class="section table-of-contents-link" href="#align-self"><span class="section table-of-contents-text">align-self</span></a></li></ol></li><li class="section table-of-contents-item section table-of-contents-level-2"><a class="section table-of-contents-link" href="#参考文章"><span class="section table-of-contents-text">参考文章</span></a></li></ol>
</div>


            <div class="entry pink-link-context">
                <p>Flexbox是弹性盒子的引文缩写flexible-box,弹性盒子布局是新的CSS3布局模型，它主要用于…<br><a id="more"></a></p>
<h2 id="flex是什么？"><a href="#flex是什么？" class="headerlink" title="flex是什么？"></a>flex是什么？</h2><p>flexbox是弹性盒子的引文缩写flexible-box,弹性盒子布局是新的CSS3布局模型，它主要使盒模型内的元素布局更加方便，它的布局可以是响应式的，即使盒内元素是动态的或不知道元素的尺寸，也能将元素更方便的布局。</p>
<h2 id="flex容器的主要特点"><a href="#flex容器的主要特点" class="headerlink" title="flex容器的主要特点"></a>flex容器的主要特点</h2><p>在不同尺寸的屏幕上，修改子元素的宽高，使用子元素尽可能的使用容器的可用空间。</p>
<h2 id="Flex的使用范围及注意"><a href="#Flex的使用范围及注意" class="headerlink" title="Flex的使用范围及注意"></a>Flex的使用范围及注意</h2><p>1、任何一个容器都能指定为Flex布局，行内元素也可以<br>2、在Webkit内核的浏览器上使用Flex，必须加上-webkit前缀。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">.flex-container &#123;</div><div class="line">  display: -webkit-flex; /* Safari */</div><div class="line">  display: flex;</div><div class="line">&#125;</div><div class="line">/*行内元素*/</div><div class="line">.flex-container &#123;</div><div class="line">  display: -webkit-inline-flex; /* Safari */</div><div class="line">  display: inline-flex;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>3、flex布局被用于小型应用组件，处理大型布局可以用栅格布局<br>4、这个属性是设置在父元素上的，它的子元素会自动的变成flex-item<br>5、使用Flex布局以后，子元素的float、clear和vertical-align属性将失效。</p>
<h2 id="flex容器及flex容器子元素示意图"><a href="#flex容器及flex容器子元素示意图" class="headerlink" title="flex容器及flex容器子元素示意图"></a>flex容器及flex容器子元素示意图</h2><p>这个图描述了flex容器和它的子元素的一些信息<br><img src="/images/flex容器及flex容器子元素术语示意图.png" alt="flex容器及flex容器子元素示意图"></p>
<h2 id="flexbox的属性"><a href="#flexbox的属性" class="headerlink" title="flexbox的属性"></a>flexbox的属性</h2><p>这些属性可以分为两组，<br>一、设置在flex容器（flex container）上的属性：<br>1、flex-direction<br>2、flex-wrap<br>3、flex-flow<br>4、justify-content<br>5、align-items<br>6、align-content</p>
<p>二、是设置在flex容器子元素（flex item）上的属性：<br>1、order<br>2、flex-grow<br>3、flex-shrink<br>4、flex-basis<br>5、flex<br>6、align-self</p>
<h2 id="flex容器属性"><a href="#flex容器属性" class="headerlink" title="flex容器属性"></a>flex容器属性</h2><p>注意：<br>1、所有column-*的属性在flex容器中设置都无效<br>2、伪元素::first-line和::first-letter都不能在flex容器中使用</p>
<h3 id="flex-direction"><a href="#flex-direction" class="headerlink" title="flex-direction"></a>flex-direction</h3><p>这个属性是决定容器子元素在flex容器中怎样排布的，通过设置主轴的方向，可以决定子元素是按哪个方向排布的，方向主要有水平和垂直，水平方向有两个值，垂直方向有两个值，默认值是row<br>1、水平方向<br>row  水平方向从左到右排列<br>row-reverse 水平方向从右向左排列<br>2、垂直方向<br>column 垂直方向从上到下排列<br>column-reverse 垂直方向从下到上排列</p>
<h3 id="flex-wrap"><a href="#flex-wrap" class="headerlink" title="flex-wrap"></a>flex-wrap</h3><p>这个属性是控制flex容器排布它的子元素是在一行还是多行，如果设置的多行，当子元素没有空间在一行上显示时，就会另起一行来放置上一行排不下的子元素，这个属性有三个值，默认值为nowrap<br>1、nowrap<br>子元素排布在一行，默认是子元素被压缩来适应flex容器的宽度<br>2、wrap<br>子元素显示在多行，按照从左到右、从上到下进行排布<br>3、wrap-reverse<br>子元素显示在多行，按照从左到右、从下到上进行排布</p>
<h3 id="flex-flow"><a href="#flex-flow" class="headerlink" title="flex-flow"></a>flex-flow</h3><p>这个属性是flex-direction和flex-wrap的快速设置，默认为row nowrap<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">.flex-container &#123;</div><div class="line">  -webkit-flex-flow: &lt;flex-direction&gt; || &lt;flex-wrap&gt;; /* Safari */</div><div class="line">  flex-flow:         &lt;flex-direction&gt; || &lt;flex-wrap&gt;;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h3 id="justify-content"><a href="#justify-content" class="headerlink" title="justify-content"></a>justify-content</h3><p>该属性是设置flex容器中当前行的flex items沿着主轴方向进行排列的方式，它的作用是当在同一行所有flex items是不可变的，或者可变但是宽高已经到达了它们的最大值时如何分配当前行的剩余空间，该属性有5个属性值，默认值为flex-start，下面的属性解释以flex-direction的值为row为例<br>1、flex-start<br>所有的子元素都排列在flex容器的左边,这个效果如同给所有的子元素设置了float:left<br>2、flex-end<br>所有的子元素都排列在flex容器的右边，这个效果如同给所有的子元素设置了float:right<br>3、center<br>所有的子元素都排列在flex容器的中间，这个效果就如同给容器设置了相同的padding-left和padding-right值，让所有的子元素都挤到容器的中间<br>4、space-between<br>这个使所有子元素的间隔相等，第一个子元素和最后一个子元素紧邻在容器的边上，这个效果就好像除了最后一个子元素，其他的子元素都设置了相同的margin-left值<br>5、space-around<br>这个属性值是让每一个子元素左右都有相等的空间距离，这个效果如同给所有的子元素都设置了相同的margin-left和margin-right值</p>
<h3 id="align-items"><a href="#align-items" class="headerlink" title="align-items"></a>align-items</h3><p>该属性是设置flex容器当前行交叉轴上的排列方式，该属性有5个属性值，默认值为stretch，下面的属性解释以flex-direction的值为row为例<br>1、stretch<br>该属性值是让所有的子元素的高度（宽度）等于交叉轴方向容器的高度（宽度）<br>2、flex-start<br>该属性值是让所有的子元素都靠在交叉轴的起始位置<br>3、flex-end<br>该属性值是让所有的子元素都靠在交叉轴的结束位置<br>4、center<br>该属性值是让所有的子元素都在交叉轴的中间位置排列<br>5、baseline<br>该属性值是让所有的子元素按照它们的基线进行排列</p>
<h3 id="align-content"><a href="#align-content" class="headerlink" title="align-content"></a>align-content</h3><p>该属性是用来排列flex容器内它的所有的子元素所组成的行，分配交叉轴的剩余空间到行与行之间，形成行与行之间的距离，该属性有6个值，默认值为stretch<br>注意：这个属性只有在flex容器有多行子元素时才有效<br>1、stretch<br>该属性值是在每一行之后分配相同的空间，效果如同给每行都设置margin-bottom值，这样行与行之间就有了间距<br>2、flex-start<br>该属性值是所有的行都向交叉轴起始端堆积，行与行之间没有距离<br>3、flex-end<br>该属性值是所有的行都向交叉轴结束端堆积，行与行之间没有距离<br>4、center<br>该属性值是所有的行都向交叉轴中间位置堆积，行与行之间没有距离<br>5、space-between<br>该属性值是在行与行之间分配相同的空间，第一行和最后一行都紧邻flex容器<br>6、space-around<br>该属性值是在每一行上下都分配相同的空间</p>
<h2 id="flex容器子元素属性"><a href="#flex容器子元素属性" class="headerlink" title="flex容器子元素属性"></a>flex容器子元素属性</h2><p>注意：<br>1、float、clear、vertical-align在flex容器子元素上都没有效果<br>2、子元素不能溢出flex容器</p>
<h3 id="order"><a href="#order" class="headerlink" title="order"></a>order</h3><p>该属性是控制flex容器里面的子元素显示的顺序，默认的顺序是按照初始化被添加时的顺序，该属性的属性值为整数，默认的属性值为0</p>
<h3 id="flex-grow"><a href="#flex-grow" class="headerlink" title="flex-grow"></a>flex-grow</h3><p>该属性是控制子元素分配空间大小的，也就是在分配可用空间的时候，该子元素相对于其他的子元素能够获取可用空间的大小，该属性值为整数，整数值越大占用的可用空间越大，负数无效，默认的值为0</p>
<h3 id="flex-shrink"><a href="#flex-shrink" class="headerlink" title="flex-shrink"></a>flex-shrink</h3><p>该属性也是控制子元素分配空间大小的，也就是在分配可用空间的时候，该子元素相对于其他的子元素能够获取可用空间的大小，该属性值为整数，整数值越大占用的可用空间越小，负数无效，默认的值为1</p>
<h3 id="flex-basis"><a href="#flex-basis" class="headerlink" title="flex-basis"></a>flex-basis</h3><p>该属性的作用就是在可用空间被分配之前设置子元素的宽高，默认况下所有的子元素都是相同的宽高，也可以设定子元素的初始尺寸，默认值是auto<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">.flex-item &#123;</div><div class="line">  -webkit-flex-basis: auto | &lt;width&gt;; /* Safari */</div><div class="line">  flex-basis:         auto | &lt;width&gt;;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h3 id="flex"><a href="#flex" class="headerlink" title="flex"></a>flex</h3><p>该属性是flex-grow、flex-shrink、flex-basis属性的合写，默认值是0 1 auto<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">.flex-item &#123;</div><div class="line">  -webkit-flex: none | auto | [ &lt;flex-grow&gt; &lt;flex-shrink&gt;? || &lt;flex-basis&gt; ]; /* Safari */</div><div class="line">  flex:         none | auto | [ &lt;flex-grow&gt; &lt;flex-shrink&gt;? || &lt;flex-basis&gt; ];</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h3 id="align-self"><a href="#align-self" class="headerlink" title="align-self"></a>align-self</h3><p>该属性是对子元素的排列(在flex容器中通过align-items设置的排列)进行单独的重写，覆盖原有的通过align-items对它设置的排布样式,默认值为auto<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">.flex-item &#123;</div><div class="line">  -webkit-align-self: auto | flex-start | flex-end | center | baseline | stretch; /* Safari */</div><div class="line">  align-self:         auto | flex-start | flex-end | center | baseline | stretch;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h2><p><a href="https://scotch.io/tutorials/a-visual-guide-to-css3-flexbox-properties" target="_blank" rel="external">A Visual Guide to CSS3 Flexbox Properties</a></p>

                
<p class="pink-link-context">
    <a href="/2016/02/26/WebSocket/" rel="next" title="WebSocket实例运用">
    上一篇：WebSocket实例运用
  </a>
</p>



<p class="pink-link-context">
    <a href="/2015/12/08/nodejs笔记1/" rel="next" title="nodejs笔记">
    下一篇：nodejs笔记
  </a>
</p>


            </div>
			
        </div>
    </div>
</article>




    <section id="comment">
        <!-- 多说评论框 start -->
        <div id="ds-thread" class="ds-thread" data-thread-key="2016/01/15/Flex学习/" data-title="Flex学习" data-url="http://yalesuperman.oschina.io/2016/01/15/Flex学习/"></div>
    <!-- 多说评论框 end -->
    <!-- 多说公共JS代码 start (一个网页只需插入一次) -->
    <script type="text/javascript">
    var pathname = location.pathname;

    var duoshuoQuery = {short_name:"yalesuperman"};
        (function() {
            if(pathname === '/about/') {
                return;
            }
            var ds = document.createElement('script');
            ds.type = 'text/javascript';ds.async = true;
            ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
            ds.charset = 'UTF-8';
            (document.getElementsByTagName('head')[0] 
             || document.getElementsByTagName('body')[0]).appendChild(ds);
        })();
        </script>
    <!-- 多说公共JS代码 end -->

    </section>



</div>

        <div class="fixed-action-btn float-sitemap">
    <a class="btn-floating btn-large pink">
      <i class="fa fa-caret-square-o-up"></i>
    </a>
    <ul>
      <li><a class="btn-return-top btn-floating waves-effect green" title="回到顶部"><i class="fa fa-arrow-circle-o-up"></i></a></li>
      <li><a class="btn-floating waves-effect button-collapse yellow darken-1"  data-activates="main-menu" title="menu"><i class="fa fa-navicon"></i></a></li>
    </ul>
  </div>

    </main>
    <footer class="page-footer black darken-1">
    
    <div class="container">
        <div class="row">
            
            <div class="social-group col m4 s12">
                <h5 class="white-text">社交</h5>
                
                    <a class="social-link" href="https://github.com/NotsayJustdo" target="_blank">
                        <i class="fa fa-2x fa-github"></i>
                    </a>
                
                    <a class="social-link" href="" target="_blank">
                        <i class="fa fa-2x fa-rss"></i>
                    </a>
                
                <div class="site-visitors-container white-text">
                    <span>
                        <i class="fa fa-user"></i>
                        <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
                    </span>
                    <span>&nbsp;|&nbsp;</span>
                    <span>
                        <i class="fa fa-eye"></i>
                        <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
                    </span>
                </div>
            </div>
            

            
        </div>
    </div>
    

    <div class="footer-copyright pink-link-context">
        <div class="container">
            © 2016 yalesuperman, All rights reserved.
            <p class="right" style="margin-top: 0;">本博客由 <a href="https://hexo.io">Hexo</a> 强力驱动 | 主题 <a href="https://github.com/raytaylorlin/hexo-theme-raytaylorism">raytaylorism</a></p>
        </div>
    </div>
</footer>


    <noscript>
    <div class="noscript">
        <p class="center-align">当前网速较慢或者你使用的浏览器不支持博客特定功能，请尝试刷新或换用Chrome、Firefox等现代浏览器</p>
    </div>
</noscript>
<div class="noscript">
    <p class="center-align">当前网速较慢或者你使用的浏览器不支持博客特定功能，请尝试刷新或换用Chrome、Firefox等现代浏览器</p>
</div>


<script src="/js/jquery.min.js"></script>
<script src="/js/materialize.min.js"></script>
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

<script>
    (function($) {
        $(document).ready(function() {
            // 隐藏禁用javascript（针对微信内置浏览器）的提示
            $('.noscript').hide();

            // 图片缩放效果
            var $imgs = $('img').not('.slider-image').not('.avatar-image').not('.carousel-image').not('.card-cover-image').not('.qrcode');

            // 给图片加上点击放大效果（materialbox插件）
            $imgs.addClass('materialboxed').each(function(i, el) {
                $(this).attr('data-caption', $(this).attr('alt') || ' ');
            }).materialbox();

            // 优化表格的显示
            $('table').each(function() {
                var $table = $(this);
                // 除去多行代码的情况
                if ($table.find('pre').length == 0) {
                    $table.addClass('responsive-table striped bordered');
                }
            });

            // 首页幻灯片
            $('.slider').slider({indicators: false, full_width: true, interval: 8000});

            $(".button-collapse").sideNav();
            $(".category-menu").sideNav();

            // 针对gallery post
            $('.carousel').carousel({full_width: true});
            $('.carousel-control.prev').click(function() {
                $('.carousel').carousel('prev');
            });
            $('.carousel-control.next').click(function() {
                $('.carousel').carousel('next');
            });

            // 文章目录
            $('article').not('.simple-article').find('h1').add('h2').add('h3').add('h4').add('h5').add('h6').scrollSpy();

            // 目录随屏幕滚动（防止目录过长越过footer）
            var $toc = $('.toc');
            var scrollTargetTop = 0;
            $(window).scroll(function() {
                var $activeLink = $toc.find('a.active.section');
                if ($(window).scrollTop() < 100) {
                    scrollTargetTop = 0;
                } else {
                    if ($activeLink[0]) {
                        scrollTargetTop = $activeLink.offset().top - $toc.offset().top;
                    }
                }
                $toc.css('top', '-' + scrollTargetTop + 'px');
            });

            // 修正文章目录的left-border颜色
            var color = $('.table-of-contents-text').css('color');
            $('.table-of-contents-link').css('border-left-color', color);

            // 针对移动端做的优化：FAB按钮点击一下收回
            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                $('.fixed-action-btn').addClass('click-to-toggle');
            }
            // 回到顶部
            $('.btn-return-top').click(function() {
                $('body, html').animate({
                    scrollTop: 0
                }, 500);
            });

            // 重置读书页面的Tab标签页的颜色
            $('li.tab a').hover(function() {
                $(this).toggleClass('text-lighten-4');
            });
            $('.indicator').addClass('pink lighten-2');

            
            // 添加new标签
            $('.menu-reading, .menu-about').append('<span class="new badge pink"></span>');
            

            // 搜索功能
            $('.modal-trigger').leanModal({
                // 打开搜索框时自动聚焦
                ready: function() {
                    if ($('#search').is(":visible")) {
                        $('#search-input').focus();
                    }
                }
            });
            var searchXml = "search.xml";
            if (searchXml.length == 0) {
             	searchXml = "search.xml";
            }
            var searchPath = "/" + searchXml;
            initSearch(searchPath, 'search-input', 'search-result');
        });

        // 初始化搜索与匹配函数
        var initSearch = function(path, search_id, content_id) {
            'use strict';
            $.ajax({
                url: path,
                dataType: "xml",
                success: function(xmlResponse) {
                    // get the contents from search data
                    var datas = $("entry", xmlResponse).map(function() {
                        return {
                            title: $("title", this).text(),
                            content: $("content", this).text(),
                            url: $("url", this).text()
                        };
                    }).get();
                    var $input = document.getElementById(search_id);
                    var $resultContent = document.getElementById(content_id);
                    $input.addEventListener('input', function() {
                        var str = '<ul class=\"search-result-list\">';
                        var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                        $resultContent.innerHTML = "";
                        if (this.value.trim().length <= 0) {
                            return;
                        }
                        // perform local searching
                        datas.forEach(function(data) {
                            var isMatch = true;
                            var content_index = [];
                            var data_title = data.title.trim().toLowerCase();
                            var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                            var data_url = data.url;
                            var index_title = -1;
                            var index_content = -1;
                            var first_occur = -1;
                            // only match artiles with not empty titles and contents
                            if (data_title != '' && data_content != '') {
                                keywords.forEach(function(keyword, i) {
                                    index_title = data_title.indexOf(keyword);
                                    index_content = data_content.indexOf(keyword);
                                    if (index_title < 0 && index_content < 0) {
                                        isMatch = false;
                                    } else {
                                        if (index_content < 0) {
                                            index_content = 0;
                                        }
                                        if (i == 0) {
                                            first_occur = index_content;
                                        }
                                    }
                                });
                            }
                            // show search results
                            if (isMatch) {
                                keywords.forEach(function(keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    data_title = data_title.replace(regS, "<span class=\"search-keyword pink lighten-2\">" + keyword + "</span>");
                                });

                                str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                                var content = data.content.trim().replace(/<[^>]+>/g, "");
                                if (first_occur >= 0) {
                                    // cut out 100 characters
                                    var start = first_occur - 20;
                                    var end = first_occur + 80;
                                    if (start < 0) {
                                        start = 0;
                                    }
                                    if (start == 0) {
                                        end = 100;
                                    }
                                    if (end > content.length) {
                                        end = content.length;
                                    }
                                    var match_content = content.substring(start, end);
                                    // highlight all keywords
                                    keywords.forEach(function(keyword) {
                                        var regS = new RegExp(keyword, "gi");
                                        match_content = match_content.replace(regS, "<span class=\"search-keyword pink lighten-2\">" + keyword + "</span>");
                                    });

                                    str += "<p class=\"search-result\">..." + match_content + "...</p>"
                                }
                                str += "</li>";
                            }
                        });
                        str += "</ul>";
                        $resultContent.innerHTML = str;
                    });
                }
            });
        }
    })(jQuery);
</script>


<script src="/js/prettify.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("pre").addClass("prettyprint");
        prettyPrint();
    });
</script>






<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript" async
  src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>



</body>
</html>
